package com.cj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cj.pojo.entity.Student;
import com.cj.pojo.until.Result;
import com.cj.pojo.vo.StudentVo;
import com.cj.service.StudentService;
import com.cj.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student>
    implements StudentService{

@Autowired
private  StudentMapper studentMapper;
    @Override
    public Result findByPage(Integer current, Integer pageSize, StudentVo studentVo) {
        Page<Student> page = new Page<>(current,pageSize);
        QueryWrapper<Student> wrapper = new QueryWrapper<>();
            if (StringUtils.hasText(studentVo.getName())){
                wrapper.like("name",studentVo.getName());
            }

        IPage<Student> byPage = studentMapper.findByPage(page, wrapper);
        return  new Result(200,"分页条件查询成功",byPage);

    }
}




